package com.magenta.maxoptra.dto;

import java.io.Serializable;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: KuznetsovD
 * Date: 18.07.12
 * Time: 12:38
 * To change this template use File | Settings | File Templates.
 */
public class Route implements Serializable{

    private static final long serialVersionUID = 509235357268328L;

    private double distance;
    private long duration;
    private double pathDistance;
    List<GeoLocationRecord> path;

    public Route(double distance, long duration, List<GeoLocationRecord> path) {
        this.distance = distance;
        this.duration = duration;
        this.path = path;
        calcPathDistance(this.path);
    }

    public double getPathDistance() {
        return pathDistance;
    }

    public List<GeoLocationRecord> getPath() {
        return path;
    }

    /**
     * Gets the value of the distance property.
     */
    public double getDistance() {
        return distance;
    }

    /**
     * Sets the value of the distance property.
     */
    public void setDistance(double value) {
        this.distance = value;
    }

    /**
     * Gets the value of the duration property.
     */
    public long getDuration() {
        return duration;
    }

    /**
     * Sets the value of the duration property.
     */
    public void setDuration(long value) {
        this.duration = value;
    }

    private void calcPathDistance(List<GeoLocationRecord> path) {
        pathDistance = 0;
        for (GeoLocationRecord geoLocationRecord : path) {
            pathDistance += geoLocationRecord.getDistanceToNextPoint();
        }
    }

}
